package persentation.presentTeacher;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;

import businesslogic.informBl.InformController;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.ImagingOpException;


public class Title extends JPanel{
	private ImageIcon titleIcon;
	private JLabel titlelLabel;
	private JFrame frame;
	
	private InformController informController;
	private InformPanel informPanel;
	
	private ImageIcon exitImageIcon;
	private ImageIcon exitImageIcon2;
	
	private ImageIcon informIcon;
	private ImageIcon informIcon2;
	
	private static ImageIcon INFORM_1=new ImageIcon("Graphics/studentGraphics/1.png");
	private static ImageIcon INFORM_2=new ImageIcon("Graphics/studentGraphics/2.png");
	
	private JButton button;
	/**
	 * Create the panel.
	 */
	public Title(String teacherName,String teacherID,final MyTabbedPane tabbedPane) {
		setSize(1100, 93);
		setLayout(null);
		setBackground(new Color(192, 192, 192));
		
		informController=new InformController(teacherID);
		
		informIcon=new ImageIcon("Graphics/teacherGraphics/1.png");
		informIcon2=new ImageIcon("Graphics/teacherGraphics/2.png");
		
		
		
		final JButton button_1 = new JButton(informIcon);
		button_1.setOpaque(false);
		button_1.setContentAreaFilled(false);
		button_1.setToolTipText("通知");
		
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				InformPanel infoPanel= new InformPanel(informController);
				System.out.println(informController==null);
				System.out.println(infoPanel==null);
				System.out.println(tabbedPane==null);
				tabbedPane.addOne("通知",infoPanel);
			}
		});
		
		button_1.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				button_1.setBounds(995, 43, 40, 40);
				button_1.setIcon(INFORM_1);
				
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				button_1.setBounds(995, 43, 40, 40);
				button_1.setIcon(INFORM_2);
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		
		
		
		button_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		button_1.setBounds(995, 43, 40, 40);
		button_1.setVisible(true);
		this.add(button_1);
		

		
		
		
		exitImageIcon=new ImageIcon("Graphics/teacherGraphics/注销图标.png");
		exitImageIcon2=new ImageIcon("Graphics/teacherGraphics/高光注销图标.png");
		button = new JButton(exitImageIcon);
		button.setFont(new Font("微软雅黑", Font.PLAIN, 29));
		button.setBounds(958, 0, 111, 40);
		button.setOpaque(false);
		button.setContentAreaFilled(false);
		button.setBorderPainted(false);
		button.setToolTipText("退出");
		add(button);
		button.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent arg0) {
				button.setBounds(958, 0, 111, 40);
				button.setIcon(exitImageIcon);
			}
			
			@Override
			public void mouseEntered(MouseEvent arg0) {
				button.setBounds(968, 0, 111, 40);
				button.setIcon(exitImageIcon2);
			}
			
			@Override
			public void mouseClicked(MouseEvent arg0) {
				int message=JOptionPane.showConfirmDialog(null,"确认退出系统？","确认",JOptionPane.YES_NO_OPTION);
				if(message==JOptionPane.YES_OPTION){
					System.exit(0);
				}
				
			}
		});
		
		
		
		titleIcon=new ImageIcon("Graphics/teacherGraphics/title.png");
		titlelLabel=new JLabel(titleIcon);
		titlelLabel.setBounds(0,-51,1100,181);
		this.add(titlelLabel);

	}
	

	
	public void setFrame(JFrame frame){
		this.frame=frame;
	}
	
	
	
	
}
